using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InputManager : BaseManager<InputManager>
{
    private bool isOpen = false;
    public InputManager()
    {
        MonoManager.Instance.AddUpdateListener(CustomUpdate);
    }

    void CheckKeyInput(KeyCode anyKey)
    {
        if (Input.GetKeyDown(anyKey))
            EventCenter.Instance.EventTrigger("AnyKeyDown", anyKey);
        if(Input.GetKeyUp(anyKey))
            EventCenter.Instance.EventTrigger("AnyKeyUp",anyKey);
    }

    public void SetOpenInput(bool isOpen)
    {
        this.isOpen = isOpen;
    }

    void CustomUpdate()
    {
        if (!isOpen)
            return;
        CheckKeyInput(KeyCode.W);
        CheckKeyInput(KeyCode.A);
        CheckKeyInput(KeyCode.S);
        CheckKeyInput(KeyCode.D);
    }
}
